<?php


class Member_Model_DbTable_Feuser_Row extends WSB_Db_Row
{

	/**
	 * @var string
	 */
	protected $passwordRepeated;

	public function init()
	{
		$this->_formConfigPath = WSB_MODULES_PATH . 'member/models/Feuser/form.config';
	}

	/**
	 * @var string
	 */
	public function getTitle()
	{
		return sprintf('%s %s', $this->lastname, $this->firstname);
	}

	/**
	 * @return void
	 */
	public function preSave()
	{
		// Passwort
		if(empty($this->password)) {
			if(empty($this->id)) {
				$this->password = '';
			} else {
				$select = $this->_table->select();
				$select->where('id=?', $this->id);
				$row = $this->_table->fetchRow($select);
				$this->password = $row->password;
			}
		} else {
			$this->password = md5($this->password);
		}
	}

	/**
	 * @return string
	 */
	public function getAuthCode()
	{
		$dataString = implode('|', $this->_data);
		return md5($dataString);
	}

}